// 游戏房间
declare function InitServerUrl(str:string);//初始化服务器地址
declare var global: any
class room extends eui.Component{
    private mainBg:eui.Image;
    // private logoObj:eui.Image;
    private btn_setUp:eui.Image;  
    private btnGPS: eui.Image = new eui.Image('locationgps_png')

    public constructor(){
        super();
        this.once(eui.UIEvent.COMPLETE,this.onComplete,this);
        this.skinName = "src/Game/gameRoom/roomSkin.exml";
    }
    private onComplete(){
        this.addChild(this.bottomLayerBg);
        this.addChild(this.centerLayerBg);
        this.addChild(this.topLayerBg);
        this.addChild(this.parentTopLayerBg);

        this.init();
        this.once(egret.Event.REMOVED_FROM_STAGE,this.onRemove,this);
        StageData.MainObj.addEventListener(Events.STAGE_SIZE,this.onStageSize,this);   
        StageData.MainObj.addEventListener(Events.MESSAGE_BREAK,this.OffLineClew,this); 
        this.btn_setUp.addEventListener(egret.TouchEvent.TOUCH_TAP,this.openSetUp,this);  

        if(GameData.roundNo){//回放
            this.btn_setUp.visible = false;
        }

        this.btnGPS.x = 200
        this.btnGPS.y = 10
        this.bottomLayerBg.addChild(this.btnGPS)
        this.btnGPS.addEventListener(egret.TouchEvent.TOUCH_TAP,()=>{
            StageData.GameRoot.ifClew("请点击用户头像查看定位信息");
        },this)

        this.addChatRoom();//添加聊天器
        StageData.MainObj.sockClose();//连接聊天服务器
    }
    private onRemove(){
        StageData.MainObj.removeEventListener(Events.STAGE_SIZE,this.onStageSize,this);
        StageData.MainObj.removeEventListener(Events.MESSAGE_BREAK,this.OffLineClew,this);
    }    

    //聊天系统
    public chatRoom:chatRoomWnd;//语音、聊天
    public addChatRoom(){
		//alert("添加");
        if(GameData.roundNo){//回放
            return;
        }
        this.closeChatRoom();
        this.chatRoom = new chatRoomWnd();
        global.chatRoom = this.chatRoom
        this.topLayerBg.addChild(this.chatRoom);
    }
	public closeChatRoom(){
        if(this.chatRoom){
            this.topLayerBg.removeChild(this.chatRoom);
            this.chatRoom = null;
        }		
	}

    //设置弹窗
    private setupObj:setUp;
    private openSetUp(){
        this.closeSetUp();
        this.setupObj = new setUp();
        this.parentTopLayerBg.addChild(this.setupObj);
        this.setupObj.addEventListener(this.setupObj.CLOSE,this.closeSetUp,this);
        this.setupObj.addEventListener(this.setupObj.EXIT_ROOM,this.ExitRoom,this);
    }
    private closeSetUp(){
        if(this.setupObj){
            this.setupObj.removeEventListener(this.setupObj.EXIT_ROOM,this.ExitRoom,this);
            this.setupObj.removeEventListener(this.setupObj.CLOSE,this.closeSetUp,this);
            this.parentTopLayerBg.removeChild(this.setupObj);
            this.setupObj = null;
        }
    }
    private onStageSize(){ 
        this.ImageXyList[0].x =  73;
        this.ImageXyList[0].y =  StageData.H - 302;

        this.ImageXyList[1].x =  StageData.W - 155;
        this.ImageXyList[1].y =  170;

        this.ImageXyList[2].x =  StageData.W - 305;
        this.ImageXyList[2].y =  20;

        this.ImageXyList[3].x =  73;
        this.ImageXyList[3].y =  175;
               
        this.handPokerXyList[0].x = 0;
        this.handPokerXyList[0].y = StageData.H - (160);

        this.handPokerXyList[1].x = StageData.W - 215;
        this.handPokerXyList[1].y = 100;
        
        this.handPokerXyList[2].x = this.ImageXyList[2].x - 560;
        this.handPokerXyList[2].y = 40;

        this.handPokerXyList[3].x = 175;
        this.handPokerXyList[3].y = 100;
        

        this.readyXYList[0].x = this.ImageXyList[0].x+90;
        this.readyXYList[0].y = this.ImageXyList[0].y+20;

        this.readyXYList[1].x = this.ImageXyList[1].x-100;
        this.readyXYList[1].y = this.ImageXyList[1].y+20;

        this.readyXYList[2].x = this.ImageXyList[2].x-100;
        this.readyXYList[2].y = this.ImageXyList[2].y+50;

        this.readyXYList[3].x = this.ImageXyList[3].x+90;
        this.readyXYList[3].y = this.ImageXyList[3].y+20;

        if(this.roomTopInfo){
            this.roomTopInfo.x = 2;//(StageData.W - this.roomTopInfo.width)/2;
            this.roomTopInfo.y = 0;
        }
       // this.updateMyHandPoker();
        this.centerPokerSize();
        this.gamePlayImageSize();
        this.tingPokerSize();
        this.operationSize();
        this.updateTimerDown();
        this.updateReadyBtn();
        this.update3RenModel();
        this.winningSize();

        this.mainBg.width = StageData.W;
        this.mainBg.height = StageData.H;
        // this.logoObj.x = (StageData.W-221)/2;
        this.btn_setUp.x = StageData.W - this.btn_setUp.width;
    }
    /*----------------@内容--------------------------------*/
    private bottomLayerBg:egret.Sprite = new egret.Sprite();
    private centerLayerBg:egret.Sprite = new egret.Sprite();
    private topLayerBg:egret.Sprite = new egret.Sprite();
    private parentTopLayerBg:egret.Sprite = new egret.Sprite();

    private ImageList:Array<gamePlayImage> = new Array();
    private ImageXyList:Array<any> = [{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}];
    private handPokerList:Array<any> = new Array();
    private handPokerXyList:Array<any> = [{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}];
    private readyList:Array<any> = new Array();
    private readyXYList:Array<any> = [{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}];
    private pointSeatIndex:Array<number> = [0,1,2,3];//方向座位号
    //private winPokerCode:Array<string> = ["guo","chi","peng","hu","gang","angang","gonggang"];//赢牌代码（0过、1吃、2碰、3胡、4明杠、5暗杠、6公杠
    private operxyList:Array<any> = [{x:615.15,y:383.9,scale:1},{x:817.5,y:198.6,scale:0.6},{x:420,y:59.05,scale:0.6},{x:110.55,y:198.60,scale:0.6}];
    

    private centerPoker:centerOutPoker;
    private roomTopInfo:roomInfo;
    private surplusPokerNum:SurplusPokerNum;

    private init(){
        //中间出的手牌
        this.centerPoker = new centerOutPoker();
        this.centerPoker.x = StageData.W/2;
        this.centerPoker.y = StageData.H/2 - 50;
        this.bottomLayerBg.addChild(this.centerPoker);
        //房间顶部信息
        this.roomTopInfo = new roomInfo();
        this.bottomLayerBg.addChild(this.roomTopInfo);
        //剩余牌数
        this.surplusPokerNum = new SurplusPokerNum();
        this.surplusPokerNum.x = 5;
        this.surplusPokerNum.y = 100;
        this.surplusPokerNum.visible = false;
        this.bottomLayerBg.addChild(this.surplusPokerNum);

        for(var i=0;i<4;i++){
            let lsImage:gamePlayImage = new gamePlayImage();
            lsImage.setOffLine(false);
            lsImage.setContent("","无名",0);
            lsImage.visible = false;
            this.bottomLayerBg.addChild(lsImage);
            this.ImageList.push(lsImage);

            let icon:egret.Bitmap = MyLibrary.createBitmapByName("okReady_png");
            icon.visible = false;
            this.bottomLayerBg.addChild(icon);
            this.readyList.push(icon);
        }
        //添加我的手牌
        this.openMyHandPoker();
        //添加其他玩家手牌
        if(GameData.roundNo){//回合            
            var lsOBJNo:playHandPokerVideo = new playHandPokerVideo();
            lsOBJNo.pointId = 1;
            this.bottomLayerBg.addChild(lsOBJNo);
            this.handPokerList.push(lsOBJNo);
            
            var lsOBJNo2:playHandPokerVideo = new playHandPokerVideo(2);
            lsOBJNo2.pointId = 2;
            this.bottomLayerBg.addChild(lsOBJNo2);
            this.handPokerList.push(lsOBJNo2);        

            var lsOBJNo3:playHandPokerVideo = new playHandPokerVideo(3);
            lsOBJNo3.pointId = 3;
            this.bottomLayerBg.addChild(lsOBJNo3);
            this.handPokerList.push(lsOBJNo3);
        }else{
            var lsOBJ:playHandPoker = new playHandPoker();
            lsOBJ.pointId = 1;
            this.bottomLayerBg.addChild(lsOBJ);
            this.handPokerList.push(lsOBJ);
            
            var lsOBJ2:playHandPoker = new playHandPoker(2);
            lsOBJ2.pointId = 2;
            this.bottomLayerBg.addChild(lsOBJ2);
            this.handPokerList.push(lsOBJ2);

            var lsOBJ3:playHandPoker = new playHandPoker(3);
            lsOBJ3.pointId = 3;
            this.bottomLayerBg.addChild(lsOBJ3);
            this.handPokerList.push(lsOBJ3);
        }
              
        let lsTimer = egret.setTimeout(()=>{
            egret.clearTimeout(lsTimer);
            this.onStageSize();
        },this,80);     
    }

    //添加解散游戏投票
    private votewindow:vote;
    private openVote(applyLeaveIndex:number,roomCancelTimeMillis:any,voteSeatIndexList:Array<number>){
        this.closeVote();
        this.votewindow = new vote();
        this.parentTopLayerBg.addChild(this.votewindow);
        this.votewindow.setContent(applyLeaveIndex,roomCancelTimeMillis,voteSeatIndexList);
        this.votewindow.addEventListener(this.votewindow.RETURN_VALUE,this.voteReturn,this);
    }
    //发送投票
    private voteReturn(e){        
        this.sendEixt_msg(e.data);
    }
    //玩家退出房间或投票提醒
    public ExitRoomClew(msg){        
        //if(msg.seatindex != GameData.mySeatIndex){        
            if(msg.succeed == false&&GameData.isGameRunning==true){
                this.closeTimerDown();
               // alert(msg.nickname+"离开房间");
            }
        //}
    }
    private closeVote(){
        if(this.votewindow){
            this.votewindow.removeEventListener(this.votewindow.RETURN_VALUE,this.voteReturn,this);
            this.parentTopLayerBg.removeChild(this.votewindow);
            this.votewindow = null;
        }
    }

    //添加赢牌动画
    private huCardObj:Array<winEffect>=new Array();
    private wineffect:winEffect;
    //删除胡牌特效
    private closeHuCard(){
        if(this.huCardObj){
            for(var i=0;i<this.huCardObj.length;i++){
                egret.Tween.removeTweens(this.huCardObj[i]);
                if (this.huCardObj[i].parent) {
                    this.centerLayerBg.removeChild(this.huCardObj[i]);
                }
                this.huCardObj.splice(i,1);
            }            
        }
    }
    //播放胡牌动画特效
    private playHuCardEffect(){
        var lsAction:egret.MovieClip = MyLibrary.createMovieClipByName("winEffectOver");
        lsAction.gotoAndStop(5);
        lsAction.anchorOffsetX = lsAction.width/2;
        lsAction.anchorOffsetY = lsAction.height/2;
        lsAction.scaleX = lsAction.scaleY = 2;
        lsAction.x = StageData.W/2;
        lsAction.y = StageData.H/2 - 100;
        lsAction.frameRate = 8;
        lsAction.visible = false;
        let lsTimer = egret.setTimeout(()=>{
             egret.clearTimeout(lsTimer);
             lsAction.visible = true;
             lsAction.play(0);
        },this,500);
        
        StageData.soundObj.soundSinglePlay("huCard_effect");
        this.centerLayerBg.addChild(lsAction);
        lsAction.once(egret.Event.COMPLETE,()=>{
            this.centerLayerBg.removeChild(lsAction);
            lsAction = null;
        },this);
    }
    //播放胡牌动画特效
    private playQishouHuCardEffect(soundName){
        var lsAction:egret.MovieClip = MyLibrary.createMovieClipByName("winEffectOver");
        lsAction.gotoAndStop(5);
        lsAction.anchorOffsetX = lsAction.width/2;
        lsAction.anchorOffsetY = lsAction.height/2;
        lsAction.scaleX = lsAction.scaleY = 2;
        lsAction.x = StageData.W/2;
        lsAction.y = StageData.H/2 - 100;
        lsAction.frameRate = 8;
        lsAction.visible = false;
        let lsTimer = egret.setTimeout(()=>{
             egret.clearTimeout(lsTimer);
             lsAction.visible = true;
             lsAction.play(0);
        },this,500);
        
        StageData.soundObj.soundSinglePlay(soundName);
        this.centerLayerBg.addChild(lsAction);
        lsAction.once(egret.Event.COMPLETE,()=>{
            this.centerLayerBg.removeChild(lsAction);
            lsAction = null;
        },this);
    }
    private winDetailEffect(suitPatterns) {
        // 2,"平胡"
        // 3,"抢杠胡"
        // 4,"杠上开花"
        // 9,"板板胡"
        // 12,"清一色"
        // 13,"碰碰胡"
        // 14,"将将胡"
        // 15,"海底捞月"
        // 16,"海底炮"
        // 17,"七小对"
        // 18,"豪华七小对"
        // 20,"杠上炮"
        // 21,"双豪华七小对"
        // 22,"超豪华七小对"
        if (suitPatterns) {
            const patternArr = []
            suitPatterns.forEach(pattern => {
                var imgName = ''
                switch (pattern) {
                    case 2:
                        imgName = 'zimo-text_png'
                        break
                    case 3:
                        imgName = 'qiangganghu-label_png'
                        break
                    case 4:
                        imgName = 'gangshagnkaihua-label_png'
                        break
                    case 9:
                        imgName = 'banbanhu-label_png'
                        break
                    case 12:
                        imgName = 'qingyise-label_png'
                        break
                    case 13:
                        imgName = 'pengpenghu-label_png'
                        break
                    case 14:
                        imgName = 'jiangjianghu-label_png'
                        break
                    case 15:
                        imgName = 'haidilao-label_png'
                        break
                    case 16:
                        imgName = 'haidipao-label_png'
                        break
                    case 17:
                        imgName = 'xiaoqidui-label_png'
                        break
                    case 18:
                        imgName = 'haohuaqidui-label_png'
                        break
                    case 20:
                        imgName = 'gangshagnpao-label_png'
                        break
                    case 21:
                        imgName = 'shuanghaoqidui-label_png'
                        break
                    case 22:
                        imgName = 'chaohaoqidui-label_png'
                        break
                }
                if (imgName !== '') {
                    patternArr.push(imgName)
                }
            })
            return patternArr
        }
        return []
    }
    private ziPic
    private openWinEffect(model:string,seatIndex:number,seatIndexList:Array<number>=null){
        console.log('openWinEffect', model);
        this.closeWinEffect();
        if(model == "liuju"){
            setTimeout(() => {
                StageData.soundObj.soundSinglePlay("over_no");
                var lswineffect = new winEffect(model);
                lswineffect.x = StageData.W / 2;//this.readyList[seatIndexList[i]].x;
                lswineffect.y = StageData.H / 2;//this.readyList[seatIndexList[i]].y;
                this.centerLayerBg.addChild(lswineffect);
                this.huCardObj.push(lswineffect);
                egret.Tween.get(lswineffect).to({ scaleX: 2, scaleY: 2 }, 1000);
            }, 500)
            return;
        }        

        if(seatIndexList){
            this.playHuCardEffect();
            for(let i=0;i<seatIndexList.length;i++){
                if(model == "hu"){
                    var msg = this.winMsg
                    console.log('winMsg', msg)
                    // -1 为自摸
                    if (msg.action.actionIndex === -1) {
                        msg.winnerSet.forEach((winnerSeatIndex, arrayIndex) => {
                            // const user = GameData.userData.find(data => data.seatIndex === winnerSeatIndex)
                            const detailEffects = this.winDetailEffect(msg.suitPatterns)
                            console.log('detailEffects', detailEffects);
                            const pics = []
                            detailEffects.forEach((win, index3) => {
                                if (index3 >= 1) {
                                    return
                                }
                                setTimeout(() => {
                                    var lswineffect3 = new winEffect(win);
                                    lswineffect3.x = StageData.W / 2;//this.readyList[seatIndexList[i]].x;
                                    lswineffect3.y = StageData.H / 2;//this.readyList[seatIndexList[i]].y;
                                    this.centerLayerBg.addChild(lswineffect3);
                                    this.huCardObj.push(lswineffect3);//this.ImageXyList[2].x
                                    egret.Tween.get(lswineffect3).wait(100).to({ scaleX: 2, scaleY: 2 }, 800).call(function () {
                                        console.log('aaaaaaaaaaa');
                                        this.centerLayerBg.removeChild(lswineffect3);
                                        const zimole = MyLibrary.createBitmapByName("zimo-text_png", true)
                                        setTimeout(() => {
                                            if (zimole.parent) {
                                                zimole.parent.removeChild(zimole)
                                            }
                                        }, 5000)
                                        this.ziPic = zimole
                                        this.ziPic.x = StageData.W / 2
                                        this.ziPic.y = StageData.H / 2
                                        this.centerLayerBg.addChild(this.ziPic)
                                        egret.Tween.removeTweens(lswineffect3)
                                        egret.Tween.get(this.ziPic).to({ x: this.ImageList[seatIndexList[i]].x + (this.ImageList[seatIndexList[i]].width / 2), y: this.ImageList[seatIndexList[i]].y + (this.ImageList[seatIndexList[i]].height / 2), scaleX: 1, scaleY: 1 }, 1000)
                                            .call(() => egret.Tween.removeTweens(this.ziPic))
                                    }, this)
                                }, 2000 * index3)
                            })
                            // if (detailEffects.length >= 1) {
                            //     var lswineffect3 = new winEffect(detailEffects[0]);
                            //     lswineffect3.x = StageData.W / 2;//this.readyList[seatIndexList[i]].x;
                            //     lswineffect3.y = StageData.H / 2;//this.readyList[seatIndexList[i]].y;
                            //     this.centerLayerBg.addChild(lswineffect3);
                            //     this.huCardObj.push(lswineffect3);//this.ImageXyList[2].x
                            //     egret.Tween.get(lswineffect3).wait(600).to({scaleX:2,scaleY:2},1000).call(function() {
                            //         console.log('aaaaaaaaaaa');
                            //         this.centerLayerBg.removeChild(lswineffect3);
                            //         this.ziPic = MyLibrary.createBitmapByName("zimo-text_png",true);
                            //         this.ziPic.x = StageData.W / 2
                            //         this.ziPic.y = StageData.H / 2
                            //         this.centerLayerBg.addChild(this.ziPic)
                            //         egret.Tween.get(this.ziPic).to({x:this.ImageList[seatIndexList[i]].x+(this.ImageList[seatIndexList[i]].width/2),y:this.ImageList[seatIndexList[i]].y+(this.ImageList[seatIndexList[i]].height/2),scaleX:1,scaleY:1},1000)
                            //         .wait(4000).call(function() {
                            //             if (this.ziPic.parent) {
                            //                 this.ziPic.parent.removeChild(this.ziPic)
                            //             }
                            //         }, this)
                            //     }, this)
                            // }
                            // detailEffects.forEach((effectsName, effectsNameIndex) => {
                            //     var lswineffect = new winEffect(effectsName);
                            //     lswineffect.x = StageData.W / 2;//this.readyList[seatIndexList[i]].x;
                            //     lswineffect.y = StageData.H / 2;//this.readyList[seatIndexList[i]].y;
                            //     this.centerLayerBg.addChild(lswineffect);
                            //     this.huCardObj.push(lswineffect);//this.ImageXyList[2].x
                            //     egret.Tween.get(lswineffect).wait(600 * effectsNameIndex).to({scaleX:2,scaleY:2},1000).wait(1000)
                            //     .to({x:this.ImageList[seatIndexList[i]].x+(this.ImageList[seatIndexList[i]].width/2),y:this.ImageList[seatIndexList[i]].y+(this.ImageList[seatIndexList[i]].height/2),scaleX:1,scaleY:1},1000)
                            //     .wait(6000).call(function() {
                            //         this.ziPic = MyLibrary.createBitmapByName("zimo-text_png",true);
                            //         this.ziPic.x = lswineffect.x
                            //         this.ziPic.y = lswineffect.y
                            //         this.centerLayerBg.addChild(this.ziPic)
                            //         setTimeout(function() {
                            //             if (this.ziPic.parent) {
                            //                 this.ziPic.parent.removeChild(this.ziPic)
                            //             }
                            //         }, 4000)
                            //         this.centerLayerBg.removeChild(lswineffect);
                            //     }, this)
                            // })

                            // var lswineffect = new winEffect('zimo');
                            // lswineffect.x = StageData.W / 2;//this.readyList[seatIndexList[i]].x;
                            // lswineffect.y = StageData.H / 2;//this.readyList[seatIndexList[i]].y;
                            // this.centerLayerBg.addChild(lswineffect);
                            // this.huCardObj.push(lswineffect);//this.ImageXyList[2].x
                            // egret.Tween.get(lswineffect).wait(600).to({scaleX:2,scaleY:2},1000).wait(1000).to({x:this.ImageList[seatIndexList[i]].x+(this.ImageList[seatIndexList[i]].width/2),y:this.ImageList[seatIndexList[i]].y+(this.ImageList[seatIndexList[i]].height/2),scaleX:1,scaleY:1},1000)
                            // .wait(6000).call(function() {
                            //     this.centerLayerBg.addChild(lswineffect);
                            // }, this);
                        }) 
                    } else {
                        // msg.winnerSet.forEach(winnerSeatIndex => {
                        //     // const user = GameData.userData.find(data => data.seatIndex === winnerSeatIndex)
                        //     var lswineffect = new winEffect('dianpao');
                        //     lswineffect.x = StageData.W / 2;//this.readyList[seatIndexList[i]].x;
                        //     lswineffect.y = StageData.H / 2;//this.readyList[seatIndexList[i]].y;
                        //     this.centerLayerBg.addChild(lswineffect);
                        //     this.huCardObj.push(lswineffect);//this.ImageXyList[2].x
                        //     egret.Tween.get(lswineffect).to({scaleX:2,scaleY:2},500).wait(5000).to({x:this.ImageList[seatIndexList[i]].x+(this.ImageList[seatIndexList[i]].width/2),y:this.ImageList[seatIndexList[i]].y+(this.ImageList[seatIndexList[i]].height/2),scaleX:1,scaleY:1},1000)
                        //     .wait(6000).call(function() {
                        //         this.centerLayerBg.addChild(lswineffect);
                        //     }, this);
                        // }) 
                        const detailEffects = this.winDetailEffect(msg.suitPatterns)
                        console.log('detailEffects', detailEffects);
                        if (detailEffects.length >= 1) {
                            var lswineffect2 = new winEffect(detailEffects[0]);
                            lswineffect2.x = StageData.W / 2;//this.readyList[seatIndexList[i]].x;
                            lswineffect2.y = StageData.H / 2;//this.readyList[seatIndexList[i]].y;
                            this.centerLayerBg.addChild(lswineffect2);
                            this.huCardObj.push(lswineffect2);//this.ImageXyList[2].x
                            egret.Tween.get(lswineffect2).wait(100).to({ scaleX: 2, scaleY: 2 }, 800).call(function () {
                                console.log('aaaaaaaaa');
                                this.centerLayerBg.removeChild(lswineffect2);
                                const zimole = MyLibrary.createBitmapByName("dianpao-text_png", true)
                                setTimeout(function() {
                                    if (zimole.parent) {
                                        zimole.parent.removeChild(zimole)
                                    }
                                }, 5000)
                                this.ziPic = zimole
                                this.ziPic.x = StageData.W / 2
                                this.ziPic.y = StageData.H / 2
                                this.centerLayerBg.addChild(this.ziPic)
                                egret.Tween.removeTweens(lswineffect2)
                                egret.Tween.get(this.ziPic).to({ x: this.ImageList[seatIndexList[i]].x + (this.ImageList[seatIndexList[i]].width / 2), y: this.ImageList[seatIndexList[i]].y + (this.ImageList[seatIndexList[i]].height / 2), scaleX: 1, scaleY: 1 }, 1000)
                                    .call(() => {egret.Tween.removeTweens(this.ziPic)})
                            }, this)
                        }
                        console.log('seatIndexList', seatIndexList);
                        // detailEffects.forEach((effectsName, effectsNameIndex) => {
                        //     var lswineffect = new winEffect(effectsName);
                        //     lswineffect.x = StageData.W / 2;//this.readyList[seatIndexList[i]].x;
                        //     lswineffect.y = StageData.H / 2;//this.readyList[seatIndexList[i]].y;
                        //     this.centerLayerBg.addChild(lswineffect);
                        //     this.huCardObj.push(lswineffect);//this.ImageXyList[2].x
                        //     egret.Tween.get(lswineffect).wait(600 * effectsNameIndex).to({scaleX:2,scaleY:2},1000).wait(1000)
                        //     .to({x:this.ImageList[seatIndexList[i]].x+(this.ImageList[seatIndexList[i]].width/2),y:this.ImageList[seatIndexList[i]].y+(this.ImageList[seatIndexList[i]].height/2),scaleX:1,scaleY:1},1000)
                        //     .call(function() {
                        //         this.ziPic = MyLibrary.createBitmapByName("dianpao-text_png",true);
                        //         this.ziPic.x = lswineffect.x
                        //         this.ziPic.y = lswineffect.y
                        //         this.centerLayerBg.addChild(this.ziPic)
                        //         this.centerLayerBg.removeChild(lswineffect);
                        //     }, this)
                        // })

                        var lswineffect = new winEffect('fangpao');
                        lswineffect.x = this.ImageList[msg.action.actionIndex].x+(this.ImageList[msg.action.actionIndex].width/2);//this.readyList[seatIndexList[i]].x;
                        lswineffect.y = this.ImageList[msg.action.actionIndex].y+(this.ImageList[msg.action.actionIndex].height/2);//this.readyList[seatIndexList[i]].y;
                        this.centerLayerBg.addChild(lswineffect);
                        this.huCardObj.push(lswineffect);//this.ImageXyList[2].x
                        egret.Tween.get(lswineffect)
                            .wait(8000).call(function() {
                                    this.centerLayerBg.addChild(lswineffect);
                                    egret.Tween.removeTweens(lswineffect)
                                }, this)

                    }
                    // var lswineffect = new winEffect(model);
                    // lswineffect.x = StageData.W/2;//this.readyList[seatIndexList[i]].x;
                    // lswineffect.y = StageData.H/2;//this.readyList[seatIndexList[i]].y;
                    // this.centerLayerBg.addChild(lswineffect);
                    // this.huCardObj.push(lswineffect);//this.ImageXyList[2].x
                    // egret.Tween.get(lswineffect).wait(600).to({scaleX:2,scaleY:2},1000).wait(1000).to({x:this.ImageList[seatIndexList[i]].x+(this.ImageList[seatIndexList[i]].width/2),y:this.ImageList[seatIndexList[i]].y+(this.ImageList[seatIndexList[i]].height/2),scaleX:1,scaleY:1},1000);
                 }else{
                    var lswineffect = new winEffect(model);
                    lswineffect.x = this.ImageList[seatIndexList[i]].x+(this.ImageList[seatIndexList[i]].width/2);
                    lswineffect.y = this.ImageList[seatIndexList[i]].y+(this.ImageList[seatIndexList[i]].height/2);
                    this.centerLayerBg.addChild(lswineffect);
                    lswineffect.once(lswineffect.ON_CLOSE,(e)=>{
                        this.centerLayerBg.removeChild(e.target);
                    },this);
                 } 
            }
        }else{
            switch (model) {
                case 'hu':
                    this.playHuCardEffect();

                    var lswineffect = new winEffect(model);
                    lswineffect.x = StageData.W / 2;
                    lswineffect.y = StageData.H / 2;
                    this.centerLayerBg.addChild(lswineffect);
                    this.huCardObj.push(lswineffect);
                    egret.Tween.get(lswineffect).wait(100).to({ scaleX: 2, scaleY: 2 }, 600).wait(800)
                        .to({ x: this.ImageList[seatIndex].x + (this.ImageList[seatIndex].width / 2), y: this.ImageList[seatIndex].y + (this.ImageList[seatIndex].height / 2), scaleX: 1, scaleY: 1 }, 1000)
                        .call(() => {egret.Tween.removeTweens(lswineffect)})
                    break
                case 'dasixi':
                    this.playQishouHuCardEffect(model);

                    var lswineffect = new winEffect(model);
                    lswineffect.x = StageData.W / 2;
                    lswineffect.y = StageData.H / 2;
                    this.centerLayerBg.addChild(lswineffect);
                    this.huCardObj.push(lswineffect);
                    egret.Tween.get(lswineffect).wait(100).to({ scaleX: 2, scaleY: 2 }, 600).wait(800)
                        .to({ x: this.ImageList[seatIndex].x + (this.ImageList[seatIndex].width / 2), y: this.ImageList[seatIndex].y + (this.ImageList[seatIndex].height / 2), scaleX: 1, scaleY: 1 }, 1000)
                        .call(() => {egret.Tween.removeTweens(lswineffect)})
                    break
                case 'liuliushun':
                this.playQishouHuCardEffect(model);

                    var lswineffect = new winEffect(model);
                    lswineffect.x = StageData.W / 2;
                    lswineffect.y = StageData.H / 2;
                    this.centerLayerBg.addChild(lswineffect);
                    this.huCardObj.push(lswineffect);
                    egret.Tween.get(lswineffect).wait(100).to({ scaleX: 2, scaleY: 2 }, 600).wait(800).to({ x: this.ImageList[seatIndex].x + (this.ImageList[seatIndex].width / 2), y: this.ImageList[seatIndex].y + (this.ImageList[seatIndex].height / 2), scaleX: 1, scaleY: 1 }, 1000)
                        .call(() => {egret.Tween.removeTweens(lswineffect)})
                    break
                case 'queyise':
                this.playQishouHuCardEffect(model);

                    var lswineffect = new winEffect(model);
                    lswineffect.x = StageData.W / 2;
                    lswineffect.y = StageData.H / 2;
                    this.centerLayerBg.addChild(lswineffect);
                    this.huCardObj.push(lswineffect);
                    egret.Tween.get(lswineffect).wait(100).to({ scaleX: 2, scaleY: 2 }, 600).wait(800).to({ x: this.ImageList[seatIndex].x + (this.ImageList[seatIndex].width / 2), y: this.ImageList[seatIndex].y + (this.ImageList[seatIndex].height / 2), scaleX: 1, scaleY: 1 }, 1000)
                        .call(() => {egret.Tween.removeTweens(lswineffect)})
                    break
                case 'banbanhu':
                this.playQishouHuCardEffect(model);

                    var lswineffect = new winEffect(model);
                    lswineffect.x = StageData.W / 2;
                    lswineffect.y = StageData.H / 2;
                    this.centerLayerBg.addChild(lswineffect);
                    this.huCardObj.push(lswineffect);
                    egret.Tween.get(lswineffect).wait(100).to({ scaleX: 2, scaleY: 2 }, 600).wait(600).to({ x: this.ImageList[seatIndex].x + (this.ImageList[seatIndex].width / 2), y: this.ImageList[seatIndex].y + (this.ImageList[seatIndex].height / 2), scaleX: 1, scaleY: 1 }, 1000)
                        .call(() => {egret.Tween.removeTweens(lswineffect)})
                    break
                default:
                    this.wineffect = new winEffect(model);
                    this.wineffect.x = this.ImageList[seatIndex].x + (this.ImageList[seatIndex].width / 2);
                    this.wineffect.y = this.ImageList[seatIndex].y + (this.ImageList[seatIndex].height / 2);
                    this.centerLayerBg.addChild(this.wineffect);
                    this.wineffect.addEventListener(this.wineffect.ON_CLOSE, this.closeWinEffect, this);
                    break
            }
            // if(model == "hu"){
            //      this.playHuCardEffect();
                
            //     var lswineffect = new winEffect(model);
            //         lswineffect.x = StageData.W/2;
            //         lswineffect.y = StageData.H/2;
            //         this.centerLayerBg.addChild(lswineffect);
            //         this.huCardObj.push(lswineffect);
            //         egret.Tween.get(lswineffect).wait(600).to({scaleX:2,scaleY:2},1000).wait(1000).to({x:this.ImageList[seatIndex].x+(this.ImageList[seatIndex].width/2),y:this.ImageList[seatIndex].y+(this.ImageList[seatIndex].height/2),scaleX:1,scaleY:1},1000);
            // }else{
            //     this.wineffect = new winEffect(model);
            //     this.wineffect.x = this.ImageList[seatIndex].x+(this.ImageList[seatIndex].width/2);
            //     this.wineffect.y = this.ImageList[seatIndex].y+(this.ImageList[seatIndex].height/2);
            //     this.centerLayerBg.addChild(this.wineffect);
            //     this.wineffect.addEventListener(this.wineffect.ON_CLOSE,this.closeWinEffect,this);
            // }
        }        
    }
    private closeWinEffect(){
        if (this.ziPic && this.ziPic.parent) {
            this.centerLayerBg.removeChild(this.ziPic)
        }
        if(this.wineffect){
            this.wineffect.removeEventListener(this.wineffect.ON_CLOSE,this.closeWinEffect,this);
            this.centerLayerBg.removeChild(this.wineffect);
            this.wineffect = null;
        }
    }

    //添加中码
    private winningcard:winningCard;
    private winningTimer;
    private isWiningShow:boolean = false;//是否已经显示过了
    private openWinningCard(msg){
        this.closeWinningCard();   
        GameData.isUpdateScore = true;//激活玩家分数可以更新
        if(!msg.zhaMaList||msg.zhaMaList.length==0){
            this.openRoundEnd(msg);
            return;
        }
        this.isWiningShow = true;     
        this.winningcard = new winningCard();
        this.topLayerBg.addChild(this.winningcard);
        this.winningcard.setContent(msg.zhaMaList);
        this.winningSize();
        this.winningcard.once(this.winningcard.ON_CLOSE,()=>{
            this.winningTimer = egret.setTimeout(()=>{
                this.closeWinningCard();
                this.openRoundEnd(msg);
                this.updateUserPoint();//刷新分数
            },this,2000);
        },this);        
    }
    private winningSize(){
        if(this.isWiningShow){
                this.winningcard.x = (StageData.W - this.winningcard.width)/2;
                this.winningcard.y = (StageData.H - this.winningcard.height)/2;
                this.winningcard.visible = true;      
        }
    }
    private closeWinningCard(){
        if(this.winningcard){
            if(this.winningTimer){
                egret.clearTimeout(this.winningTimer);
            }
            this.topLayerBg.removeChild(this.winningcard);
            this.winningcard = null;
        }
    }

    //添加回合结算
    private roundend:roundEndGame;
    private openRoundEnd(msg){
        this.closeRoundEnd();
        this.roundend = new roundEndGame();
        this.topLayerBg.addChild(this.roundend);
        this.roundend.setContent(msg);
        this.roundend.addEventListener(this.roundend.PLAYER,this.player_msg,this);
        this.centerPoker.clearPointer()
    }
    //继续游戏
    private player_msg(){
        let data = {
			commandCode: "10002",
			version: "0.1",
            step:GameData.step
		};
		Message.sendMsgToServer(data);
    }
    private closeRoundEnd(){
        GameData.tingle = false
        if(this.roundend){
            this.roundend.removeEventListener(this.roundend.PLAYER,this.player_msg,this);
            this.topLayerBg.removeChild(this.roundend);
            this.roundend = null;
        }
    }
    //添加赢牌交互操作
    private operationMc:operationBtn;
    // private openOperation(actionCard:any=null,seatIndex:number = 0, actionCards = []){
    private openOperation(actionCard:any=null,seatIndex:number = 0, candoActions = []){
        this.closeOperation();
        console.log('actionCard', actionCard);
        // console.log('actionCards', actionCards);
        // if (!actionCard) {
        //     const cardCenter = actionCards.length >= 1 ? actionCards[0] : null
        //     this.operationMc = new operationBtn(cardCenter);
        // } else {
        //     this.operationMc = new operationBtn(actionCard);
        // }
        // if (actionCards.length > 1) {
        //     this.operationMc.multi = true
        // }
        if (!actionCard) {
            const cardCenter = candoActions && candoActions[0] && candoActions[0].actionCards && candoActions[0].actionCards.length >= 1 ? candoActions[0].actionCards[0] : null
            this.operationMc = new operationBtn(cardCenter);
        } else {
            this.operationMc = new operationBtn(actionCard);
        }
        this.operationMc.candoActions = candoActions
        if (candoActions && candoActions.length >= 1 && candoActions[0].actionCards && candoActions[0].actionCards.length > 1) {
            this.operationMc.multi = true
        }
        if (candoActions && candoActions.filter(action => action.actionType === 5 || action.actionType === 6).length >= 2) {
            this.operationMc.multi = true
        }
        if (this.hideOperate) {
            this.operationMc.visible = false
        }
        this.centerLayerBg.addChild(this.operationMc);

        //let newSeatIndex:number = GameData.getUserSeatIndex(seatIndex);
        if(GameData.roundNo){//是否是回放
                this.operationMc.scaleX = this.operationMc.scaleY = this.operxyList[seatIndex].scale;
                this.operationMc.x = this.operxyList[seatIndex].x;
                this.operationMc.y = this.operxyList[seatIndex].y;     
        }else{
            this.operationSize();
        }        
        this.operationMc.addEventListener(PokerEvent.WIN_POKER,this.onWinPoker,this);
    }
    private operationSize(){
        if(!GameData.roundNo){
            if(this.operationMc){
                this.operationMc.x = StageData.W - this.operationMc.width-100;
                this.operationMc.y = StageData.H - 300;
            }
        }
    }
    public buzhanghulePokers: Array<TanpaiMy> = []
    public buzhanghule(msg) {
        const {x, y} = this.ImageXyList[msg.index]   
        const pai = new TanpaiMy()
        pai.scaleX = pai.scaleY = .5
        pai.x = x
        pai.y = y
        this.buzhanghulePokers.push(pai)
        pai.setData(msg.card)
        this.centerLayerBg.addChild(pai)     
    }
    private yaoShaiZi: YaoShaiZi = new YaoShaiZi()
    public centerPokers: Array<TanpaiMy> = []
    public hideOperate: boolean = false
    public lastShaiziTimeout = -1
    public yaoshaiziResult(msg) {
        console.log('yaoshaiziResult', msg);
        if (msg.end) {
            console.log('yaoshaiziResult jieshule!');
            this.lastShaiziTimeout = setTimeout(() => {
                this.centerPokers.forEach(pai => {
                    if (pai.parent) {
                        this.centerLayerBg.removeChild(pai)
                    }
                })
            }, 2000)
            return
        }
        if (this.lastShaiziTimeout !== -1) {
            clearTimeout(this.lastShaiziTimeout)
        }
        // 暂时隐藏按钮
        this.hideOperate = true
        const showNumer = msg.num
        const time = 0
        setTimeout(() => {
            let data = {
                commandCode: "20010",
                version: "0.1",
                index: msg.index,
                step: GameData.step
            };
            console.log('发送发牌完毕的信息');
            Message.sendMsgToServer(data);            
        }, 800)
        setTimeout(() => {
            if (msg.cards && msg.cards.length) {
                StageData.soundObj.soundSinglePlay("tingCard");
                this.centerPokers.forEach(pai => {
                    if (pai.parent) {
                        this.centerLayerBg.removeChild(pai)
                    }
                })
                this.centerPokers.length = 0
                msg.cards.forEach((card, index) => {
                    const pai = new TanpaiMy()
                    pai.scaleX = pai.scaleY = 2
                    pai.x = 360 + 150 * index
                    pai.y = 100
                    this.centerPokers.push(pai)
                    this.centerLayerBg.addChild(pai)
                    // setTimeout(() => {
                    //     if (pai.parent) {
                    //         this.centerLayerBg.removeChild(pai)
                    //     }
                    // }, 12000)
                    if (msg.cards.length === showNumer) {
                        console.log('GameData.userData', GameData.userData);
                        // const keyihu = GameData.userData.some(userData => userData.canDoActions.some(action => action.actionCode === 3))
                        // const dispearTime = keyihu ? 8000 : 3000
                        // if (keyihu) {
                        //     pai.y = 100
                        // }
                        // setTimeout(() => {
                        //     this.centerLayerBg.removeChild(pai)
                        //     this.buzhanghulePokers.forEach(buzhuangPoker => {
                        //         this.centerLayerBg.removeChild(buzhuangPoker)
                        //     })
                        //     this.buzhanghulePokers.length = 0
                        // }, 3000)
                        pai.setData(card)
                    } else {
                        if (index < showNumer) {
                            pai.setData(card)
                        } else {
                            pai.setBack()
                        }
                    }
                })
            }
            // 显示按钮
            this.hideOperate = false
            if (this.operationMc) {
                this.operationMc.visible = true
            }
        }, time)
        if (msg.dianshu) {
            this.yaoShaiZi.setResult(msg.dianshu)
            this.addChild(this.yaoShaiZi)
            this.yaoShaiZi.playAction()
        }
    }

    public qishouhuyaoshaiziResult(msg) {
        console.log('qishouhuyaoshaiziResult', msg);
        // if (msg.end) {
        //     console.log('yaoshaiziResult jieshule!');
        //     setTimeout(() => {
        //         this.centerPokers.forEach(pai => {
        //             if (pai.parent) {
        //                 this.centerLayerBg.removeChild(pai)
        //             }
        //         })
        //     }, 2000)
        //     return
        // }
        // 暂时隐藏按钮
        this.hideOperate = true
        const showNumer = msg.num
        const time = 0
        // setTimeout(() => {
        //     let data = {
        //         commandCode: "20010",
        //         version: "0.1",
        //         index: msg.index,
        //         step: GameData.step
        //     };
        //     console.log('发送发牌完毕的信息');
        //     Message.sendMsgToServer(data);            
        // }, 800)
        setTimeout(() => {
            if (msg.cards && msg.cards.length) {
                StageData.soundObj.soundSinglePlay("tingCard");
                this.centerPokers.forEach(pai => {
                    if (pai.parent) {
                        this.centerLayerBg.removeChild(pai)
                    }
                })
                this.centerPokers.length = 0
                msg.cards.forEach((card, index) => {
                    const pai = new TanpaiMy()
                    pai.scaleX = pai.scaleY = 2
                    pai.x = 360 + 150 * index
                    pai.y = 100
                    this.centerPokers.push(pai)
                    this.centerLayerBg.addChild(pai)
                    setTimeout(() => {
                        if (pai.parent) {
                            this.centerLayerBg.removeChild(pai)
                        }
                    }, 3000)
                    pai.setData(card)
                })
            }
            // 显示按钮
            this.hideOperate = false
            if (this.operationMc) {
                this.operationMc.visible = true
            }
        }, time)
        if (msg.dianshu) {
            this.yaoShaiZi.setResult(msg.dianshu)
            this.addChild(this.yaoShaiZi)
            this.yaoShaiZi.playAction()
        }
    }
    private onWinPoker(e){
        console.log('onWinPoker', e.data)
        if (this.chipaiTishi.parent){
            this.centerLayerBg.removeChild(this.chipaiTishi)
        }
        if (this.haidipai && this.haidipai.parent) {
            this.centerLayerBg.removeChild(this.haidipai)
        }
        if (this.haidilaoLabel && this.haidilaoLabel.parent) {
            this.centerLayerBg.removeChild(this.haidilaoLabel)
        }
        // this.centerPokers.forEach(poker => {
        //     setTimeout(() => {
        //         if (poker.parent) {
        //            poker.parent.removeChild(poker)
        //         }
        //     }, 3000)
        // })
        // this.centerPokers.length = 0
        switch(e.data){
            case "peng":
            //alert("碰");
            this.sendWin_msg(2);
            break;

            case "gang":
           // alert("杠"+this.winPokerGang);
            this.sendWin_msg(this.winPokerGang);
            break;

            case "hu":
            //alert("胡");
            this.sendWin_msg(3);
            break;

            case "chi":
                this.openChiChoose()
            //alert("胡");
            // this.sendWin_msg(3);
            break;

            case "qishouhu":
                // this.openChiChoose()
                console.log('qishouhu');
                this.sendWin_msg(7);
            //alert("胡");
            // this.sendWin_msg(3);
            break;

            case "gangyao":
                // this.openChiChoose()
                console.log('gangyao');
                let data = {
                    commandCode: "20008",
                    version: "0.1",
                    step: GameData.step,
                    flag: true
                };
                Message.sendMsgToServer(data);
                this.closeOperation()
            //alert("胡");
            // this.sendWin_msg(3);
            break;

            case "haidiyao":
                this.sendWin_msg(8);
                this.closeOperation()
                console.log('haidiyao');
                // this.openChiChoose()
            //alert("胡");
            // this.sendWin_msg(3);
            break;

            case "guo":
            //alert("过");
            if(this.isHaveHu == true){
                if(StageData.GameRoot.ifClew("是否确认跳过胡牌？",()=>{
                    this.sendWin_msg(0,true);
                },()=>{
                    // this.sendWin_msg(0);
                    console.log('取消跳过!!');
                })){

                }
            }else{
                this.sendWin_msg(0);
            }
            break;
            case "bu":
                // this.sendWin_msg(0);
                // console.log('buyao')
                // let data2 = {
                //     commandCode: "20007",
                //     version: "0.1",
                //     step: GameData.step,
                //     flag: false,
                //     actionCode: this.winPokerGang,
                // };
                // Message.sendMsgToServer(data2);
                // this.closeOperation()
                this.openChiChoose(false, true)
            break;
            case "gonggang":
                // this.sendWin_msg(0);
                this.openChiChoose(true)
            break;
            // todo 暗杠的选择
            case "angang":
                // this.sendWin_msg(0);
                this.openChiChoose(false, false , true)
            break;
            case "baoting":
                // this.sendWin_msg(0);
                // this.openChiChoose(true)
                console.log('baoting');
                let data22 = {
                    commandCode: "20009",
                    version: "0.1",
                    step: GameData.step,
                };
                Message.sendMsgToServer(data22);
            break;
        }
    }
    private deleteNumber:number = 0;
    private closeOperation(){        
        if(this.operationMc){
            this.operationMc.removeEventListener("size",this.operationSize,this);
            this.operationMc.removeEventListener(PokerEvent.WIN_POKER,this.onWinPoker,this);
            if (this.operationMc.parent) {
                this.centerLayerBg.removeChild(this.operationMc);
            }
            this.operationMc = null;
        }
    }
    private chiChoose: ChiChoose
    public openChiChoose(isGongGang: boolean = false, isGang: boolean = false, isAnGang: boolean = false) {
        if (!this.chiChoose) {
            this.chiChoose = new ChiChoose()
            this.chiChoose.right = 85
            this.chiChoose.bottom = 167
            this.chiChoose.addEventListener('closeChi', function() {
                this.operationMc.visible = true
                if (this.chiChoose.parent) {
                    this.removeChild(this.chiChoose)
                }
            }, this)
        }
        this.operationMc.visible = false
        this.addChild(this.chiChoose)
        console.log(isGongGang, isGang);
        if (isGongGang) {
            this.chiChoose.setChooseBuData(this.operationMc.winMsg)
        } else if (isGang){
            this.chiChoose.setChooseGangData(this.operationMc.winMsg)
        } else if (isAnGang) {
            this.chiChoose.setChooseAnGangData(this.operationMc.winMsg)
        } else {
            this.chiChoose.setChooseData(this.operationMc.winMsg)
        }
    }

    public openAngangChoose() {
        if (!this.chiChoose) {
            this.chiChoose = new ChiChoose()
            this.chiChoose.right = 85
            this.chiChoose.bottom = 167
            this.chiChoose.addEventListener('closeChi', function() {
                this.operationMc.visible = true
                if (this.chiChoose.parent) {
                    this.removeChild(this.chiChoose)
                }
            }, this)
        }
        this.operationMc.visible = false
        this.addChild(this.chiChoose)
        this.chiChoose.setChooseAngangData(this.operationMc.winMsg)
    }

    //添加听牌
    private tingPokerMc:TingPoker;
    private openTingPoker(){
        this.closeTingPoker();
        this.tingPokerMc = new TingPoker();
        this.tingPokerMc.y = StageData.H - this.tingPokerMc.height;
        this.centerLayerBg.addChild(this.tingPokerMc);
        this.tingPokerMc.addEventListener(PokerEvent.TUOGUAN_TINGPOKER_START,this.onStartTuoGuan,this);
        this.tingPokerMc.addEventListener(PokerEvent.TUOGUAN_TINGPOKER_END,this.onEndTuoGuan,this);
    }
    //请求开始托管听牌
    private onStartTuoGuan(){
        let data = {
			  commandCode: "11008",
			  version: "0.1",
			  auto:true,
              step:GameData.step
			};
			Message.sendMsgToServer(data);
        //this.tingPokerMc.setTuoGuang(true);//test
    }
    //请求关闭托管听牌
    private onEndTuoGuan(){
        let data = {
			  commandCode: "11008",
			  version: "0.1",
			  auto:false,
              step:GameData.step
			};
			Message.sendMsgToServer(data);
    }    
    private tingPokerSize(){
        if(this.tingPokerMc){
            this.tingPokerMc.y = StageData.H - this.tingPokerMc.height;
        }
    }
    private closeTingPoker(){
        if(this.tingPokerMc){
           this.tingPokerMc.removeEventListener(PokerEvent.TUOGUAN_TINGPOKER_START,this.onStartTuoGuan,this);
           this.tingPokerMc.removeEventListener(PokerEvent.TUOGUAN_TINGPOKER_START,this.onEndTuoGuan,this);
           this.centerLayerBg.removeChild(this.tingPokerMc);
           this.tingPokerMc = null;
        }
    }

    //设置中心牌坐标
    private centerPokerSize(){
        if(this.centerPoker){
            this.centerPoker.x = StageData.W/2;
            this.centerPoker.y = StageData.H/2-30;
        }
    }
    //设置玩家头像\准备图标\坐标
    private gamePlayImageSize(){
        GameData.playPic_location = this.ImageXyList;
        GameData.chat_location = this.readyXYList;
        for(var i=0;i<4;i++){
            this.ImageList[i].x = this.ImageXyList[this.handPokerList[i].pointId].x;
            this.ImageList[i].y = this.ImageXyList[this.handPokerList[i].pointId].y;

            this.readyList[i].x = this.readyXYList[this.handPokerList[i].pointId].x;
            this.readyList[i].y = this.readyXYList[this.handPokerList[i].pointId].y;

            this.handPokerList[i].x = this.handPokerXyList[this.handPokerList[i].pointId].x;
            this.handPokerList[i].y = this.handPokerXyList[this.handPokerList[i].pointId].y;
        }
    }
    //关闭隐藏准备图标
    private readyHide(){
        for(var i=0;i<4;i++){
            this.readyList[i].visible = false;
        }
    }

    //添加手牌
    private myPoker:myHandPoker;
    private openMyHandPoker(){
        /*this.closeMyHandPoker();*/      
        this.myPoker = new myHandPoker();
        this.myPoker.pointId = 0;
        this.myPoker.y = StageData.H - this.myPoker.height-160;
        this.centerLayerBg.addChild(this.myPoker);
        this.handPokerList.push(this.myPoker);
        this.myPoker.addEventListener(PokerEvent.OUT_POKER,this.onOutPoker,this);
        this.myPoker.addEventListener(PokerEvent.HAVE_POKER_START,this.startLookupoutPoker,this);
        this.myPoker.addEventListener(PokerEvent.HAVE_POKER_END,this.endLookupoutPoker,this);
    }
    /*private closeMyHandPoker(){
        if(this.myPoker){
            this.centerLayerBg.removeChild(this.myPoker);
            this.myPoker.removeEventListener(PokerEvent.OUT_POKER,this.onOutPoker,this);
            this.myPoker.removeEventListener(PokerEvent.HAVE_POKER_START,this.startLookupoutPoker,this);
            this.myPoker.removeEventListener(PokerEvent.HAVE_POKER_END,this.endLookupoutPoker,this);
            this.myPoker = null;
        }
    }*/
    private outPokerMc:handPoker;
    private outPokerData:any;
    private closePokerMc(){
        if(this.outPokerMc){
            this.topLayerBg.removeChild(this.outPokerMc);
            this.outPokerMc = null;
            this.outPokerData = null;
        }
    }
    //我的手牌
    private startLookupoutPoker(e){
        this.centerPoker.showlookupPoker(e.data.flower,e.data.value);
    }
    private endLookupoutPoker(){
        this.centerPoker.hidelookupPoker();
    }
    private onOutPoker(e){
        if(!this.outPokerMc){
            var _data = e.data.value;
            this.outPokerData = _data;
            this.outPokerMc = new handPoker();
            this.outPokerMc.setContent(e.data.value.flower+"_"+e.data.value.value+"_png");
            this.outPokerMc.anchorOffsetX = this.outPokerMc.width/2;
            this.outPokerMc.anchorOffsetY = this.outPokerMc.height/2;            
            this.topLayerBg.addChild(this.outPokerMc);
            
            if(e.data.doubleClick){
                this.outPokerMc.x = this.myPoker.x+e.data.localX;
                this.outPokerMc.y = this.myPoker.y;
                this.outPoker_msg(this.outPokerData.id);
                this.closePokerMc();
                //this.executeOutPoker(this.outPokerData.x,this.outPokerData.y,this.outPokerData.flower,this.outPokerData.value,this.outPokerData.id);
                return;
            }
            this.addEventListener(egret.TouchEvent.TOUCH_MOVE,this.onOutPoker_Move,this);
            this.addEventListener(egret.TouchEvent.TOUCH_END,this.onOutPoker_Up,this);
        }
    }
    private onOutPoker_Move(e:egret.TouchEvent){
        this.outPokerMc.x = e.stageX;
        this.outPokerMc.y = e.stageY;
        if(this.outPokerMc.y<this.myPoker.y-20){
            //console.log("松开出牌");
            //成功出牌
        }else{

        }
        if(this.outPokerMc.x >= StageData.W||this.outPokerMc.y <= 0||this.outPokerMc.x <= 0){
            this.onOutPoker_Up(null);
        }
    }
    private onOutPoker_Up(e:egret.TouchEvent){
        this.removeEventListener(egret.TouchEvent.TOUCH_MOVE,this.onOutPoker_Move,this);
        this.removeEventListener(egret.TouchEvent.TOUCH_END,this.onOutPoker_Up,this);
        if(this.outPokerMc.y<this.myPoker.y-20){
            //成功出牌
            //alert("出牌ID:"+this.outPokerData.id);
            this.outPoker_msg(this.outPokerData.id);
            if (this.outPokerData.id !== 31) {
                this.myPoker.deleteSinglePoker(this.outPokerData.id)
            }
            this.closePokerMc();
            //this.executeOutPoker();
        }else{
            this.closePokerMc();
        }   
    }
    private outPoker_msg(pokerId:number){
        let data = {
             commandCode: "20002",
             version: "0.1",
             step:GameData.step,
             cardIndex:pokerId
        };
        Message.sendMsgToServer(data);
    }
    //出牌
    private testPointId:number = 0;
    private executeOutPoker(lsx:number,lsy:number,flower,value,id){
            this.testPointId ++;
            if(this.testPointId>3){
               this.testPointId = 0;
            }
            this.myPoker.deleteSinglePoker(id);
            var lsobj:any = this.centerPoker.getOutPoker_xy(this.testPointId);
            /*var lsx:number = lsobj.x+this.centerPoker.x+19;
            var lsy:number = lsobj.y+this.centerPoker.y+27.5;*/

                egret.Tween.get(this.outPokerMc).to({scaleX:0.5,scaleY:0.5,x:lsx,y:lsy},300,egret.Ease.quadIn).call((e)=>{
                egret.Tween.removeTweens(this.outPokerMc);                             
                //test
                //this.centerPoker.updateTimerPoint(this.testPointId+1);
                this.centerPoker.addSinglePoker(this.testPointId,flower,value,id);
                //end
                this.closePokerMc();
            },this);
            //this.myPoker.deleteAppointPoker(this.outPokerData.flower,this.outPokerData.value);
           // this.myPoker.winPoker(this.outPokerData.flower,this.outPokerData.value,this.outPokerData.id,"gang");            
    }
    //打开三人模式按钮
    private readyui:egret.Bitmap = MyLibrary.createBitmapByName("okReady_png");
    private model3Renui:egret.Bitmap = MyLibrary.createBitmapByName("3renModel_icon_png");
    private model3ren:model3Ren;
    private open3RenModel(){
        this.close3RenModel();
        this.model3ren = new model3Ren();
        this.bottomLayerBg.addChild(this.model3ren);
        this.update3RenModel();
        this.model3ren.addEventListener(this.model3ren.RETURN_VALUE,this.model3ren_msg,this);
    }
    private update3RenModel(){
        if(this.model3ren){
            this.model3ren.x = (StageData.W - this.model3ren.width)/2;
            this.model3ren.y = 160;
        }
    }    
    private close3RenModel(){
        if(this.model3ren){
            this.model3ren.removeEventListener(this.model3ren.RETURN_VALUE,this.model3ren_msg,this);
            this.bottomLayerBg.removeChild(this.model3ren);
            this.model3ren = null;
        }
    }
    //开启三人模式
    private model3ren_msg(e){
        let data = {
			commandCode: "10001",
			version: "0.1",
            step:GameData.step,
            allow:e.data
		};
		Message.sendMsgToServer(data);
    }
    //三人模式UI赋值
    public getMSGInfo(msg){
        if(this.model3ren&&msg.seatIndex == GameData.mySeatIndex){
            this.model3ren.setContent(msg.allow);
        }
    }
    
    //打开准备按钮
    private readyGameBtn:startGameBtn;
    private openReadyBtn(){        
        this.closeReadyBtn();
        this.readyGameBtn = new startGameBtn(false);
        this.updateReadyBtn();
        this.bottomLayerBg.addChild(this.readyGameBtn);
    }
    private setData(ready:boolean){        
        if(this.readyGameBtn){
            this.readyGameBtn.setReady(ready);
        }
    }
    private updateReadyBtn(){
        if(this.readyGameBtn){
            this.readyGameBtn.x = (StageData.W - this.readyGameBtn.width)/2;
            this.readyGameBtn.y = StageData.H - 220;
        }
    }
    private closeReadyBtn(){
        if(this.readyGameBtn){
           this.bottomLayerBg.removeChild(this.readyGameBtn);
           this.readyGameBtn = null;
        }
    }
    //打开退出房间按钮
    private exitBtn:egret.Bitmap;
    private openExitRoom(){        
        this.closeExitRoom();
        this.exitBtn = MyLibrary.createBitmapByName("btn_exit_png");
        this.exitBtn.x = 5;
        this.exitBtn.y = 100;
        this.exitBtn.touchEnabled = true;
        this.centerLayerBg.addChild(this.exitBtn);
        this.exitBtn.addEventListener(egret.TouchEvent.TOUCH_TAP,this.ExitRoom,this);
    }  
    private closeExitRoom(){
        if(this.exitBtn){
            this.exitBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.ExitRoom,this);
            this.centerLayerBg.removeChild(this.exitBtn);
            this.exitBtn = null;
        }
    }
        
    //执行退出房间
    public ExitRoom(){        
        //游戏是否在运行
        if(GameData.isGameRunning){
            StageData.GameRoot.ifClew("确定要申请游戏结束吗?",this.sendExit_msg,()=>{});
        }else{
            StageData.GameRoot.ifClew("确定要退出房间吗?",this.sendExit_msg,()=>{});
        }
        /*if(confirm("确定要退出房间吗?")){
            if(GameData.isGameRunning){
                //alert("游戏已开始");
               this.sendExit_msg();
            }else{
               this.sendExit_msg();
            }            
		}else{
            
		}*/
    }
    //发送退出房间信息
    public sendExit_msg(){
        let data = {
			commandCode: "11002",
			version: "0.1",
            step:GameData.step
		};
		Message.sendMsgToServer(data);
    }    
    //离线提醒
    private OffLineClew(){
        //Message.stopHeart();//暂停心跳
        StageData.GameRoot.openWait(false);
         this.Reconnect_msg();
    }
    //重新连接-重连
    private ReconnectCount:number = 0;//重连次数
    private isyesReconnect:boolean = true;//是否可以重连刷新
    private Reconnect_msg(){
            GameData.reconnect = true;
            var _rooNo:string = GameData.roomNo; 
            if(this.ReconnectCount > 3 && this.isyesReconnect){//重连五次刷新页面
                window.location.href = getJSUrl();
            }
            this.ReconnectCount ++;
            //console.log("重连。。。。");
            let config = {
                user: "user",
                pass: "pass",
                roomNo:_rooNo,
                token:GameData.token,
                ignore:GameData.ignore
            }
            Message.connectServer(config,()=>{
                let data = {
                    commandCode:"11001",
                    version:"0.1",
                    step:GameData.step
                };
                Message.sendMsgToServer(data);
                //StageData.GameRoot.closeWait();
                //this.ReconnectCount = 0;
            });
           //Message.startHeart();//重新开启心跳
    }
    //11006返回信息
    public getReconnect(msg){
        //console.log("11006結算信息:"+JSON.stringify(msg));  
        StageData.MainObj.sockClose();//连接聊天服务器      
        StageData.GameRoot.closeWait();
        GameData.reconnect = false;
        this.ReconnectCount = 0;
        if(msg.sendMsgList){ 
            for(var i=0;i<msg.sendMsgList.length;i++){  
                if(msg.sendMsgList[i].commandCode == "20005"){
                    //alert("重连20005");
                    //this.openWinningCard(msg.sendMsgList[i]);  
                    this.openRoundEnd(msg.sendMsgList[i]);                   
                    break;
                }
            }
        }
    }

    /*------------------@收到Message信息-------------*/
    /*设置我的座位号并排序*/
    private isSeatindex:boolean = false;//是否已排过座位（只需要排一次座位）
    public setMySeatindex(msg){
        if(this.isSeatindex) return;//只需要排一次座位
        this.isSeatindex = true;
        GameData.mySeatIndex = msg;
        if(this.chatRoom){
            this.chatRoom.updatePoint(msg,GameData.chat_location);//聊天服务器
        }        
        this.ImageList = GameData.updatePoint(msg,this.ImageList);
        this.handPokerList = GameData.updatePoint(msg,this.handPokerList);
        this.readyList = GameData.updatePoint(msg,this.readyList);     
        this.pointSeatIndex = GameData.updatePoint(msg,this.pointSeatIndex); 
        this.operxyList = GameData.updatePoint(msg,this.operxyList);
        GameData.transformSeatIndex = this.pointSeatIndex;          
    }

    /*自动解散房间倒计时*/
    private timerObj:TimerCountDown;//倒计时对象
    public openTimerDown(time:any){
        if(time<0) return;
        this.closeTimerDown();
        this.timerObj = new TimerCountDown("自动解散房间还剩 ");
        this.timerObj.startTimer(time);
        this.bottomLayerBg.addChild(this.timerObj);
        this.timerObj.y = 10;
        this.updateTimerDown();
        this.timerObj.addEventListener("timeOver",this.closeTimerDown,this);
    }
    private updateTimerDown(){
        if(this.timerObj){
            this.timerObj.x = (StageData.W - this.timerObj.width)/2;
        }
    }
    private closeTimerDown(){
        if(this.timerObj){
            this.timerObj.removeEventListener("timeOver",this.closeTimerDown,this);
            this.bottomLayerBg.removeChild(this.timerObj);
            this.timerObj = null;
        }
    }    

    /*@更新房间信息*/
    public infoExtraTx = new egret.TextField()
    private lastRoomMsg: any = {}
    private lastGameRunning: any
    private lastturns: any
    // public updateRoomInfo = _.debounce(this.updateRoomInfoRaw, 10)
    
    public updateRoomInfo(msg:any){
        console.log('updateRoomInfo', msg)
        this.storeGameInfo(msg)
        if(msg.applyLeaveIndex > -1&&msg.roomCancelTimeMillis > -1){
            this.openVote(msg.applyLeaveIndex,msg.roomCancelTimeMillis,msg.agreeIndex);
        }else{
            this.closeVote();
        }
        if (_.isEqual(msg, this.lastRoomMsg)) {
            console.log('roomInfo isEqual');
            return 
        }

        if (_.isEqual(msg.userList, this.lastRoomMsg.userList)) {
            console.log('userList isEqual')
        } else {
            this.updateGamePlayInfo(msg.userList);
        }
        
        //let ruleTypeStr:Array<string> = ["一码全中","两个码","四个码","六个码","八个码"];        
        this.surplusPokerNum.setContent(GameData.remainCount);//剩余牌数
        if (!_.isEqual(GameData.turns, this.lastturns)) {
            this.roomTopInfo.setContent(GameData.roomNo,GameData.ruleTypeStr[GameData.ruleType-1],GameData.turns+"/"+GameData.totalTurns,msg.qiXiaoDuiWin);//房间顶部信息
            this.lastturns = GameData.turns
        }
        
        //StageData.GameRoot.clew(GameData.mySeatIndex+" : "+Number(msg.playIndex)+":"+(Number(msg.playIndex)+1));
        this.centerPoker.updateTimerPoint(GameData.mySeatIndex,Number(msg.playIndex)+1);
        //判断检查是否是自己操作
        if(GameData.outPokerIndex == GameData.mySeatIndex){
            this.myPoker.isPause(false);
        }else{
            this.myPoker.isPause(true);
        }
        if (_.isEqual(this.lastGameRunning, GameData.isGameRunning)) {
            console.log('isGameRunning isEqual')
        } else {
            if(GameData.isGameRunning){
                this.closeExitRoom();//添加退出按钮
                this.surplusPokerNum.visible = true;
            }else{            
                this.openExitRoom();//添加退出按钮
                this.surplusPokerNum.visible = false;
            }
            this.lastGameRunning = GameData.isGameRunning
        }
        
        if(GameData.isRoundGame){
            //桌上已出的牌
            this.refreshAllPoker(msg)
        } else {
            this.refreshReadyState(msg)            
        }
       // StageData.GameRoot.clew(msg.applyLeaveIndex+" : "+msg.roomCancelTimeMillis+" : "+msg.agreeIndex);
        this.updateRoomOther(msg)
        this.lastRoomMsg = msg
    }

    storeGameInfo(msg) {
        GameData.roomInfo = msg;
        GameData.isGameRunning = msg.start;//游戏是否开始状态
        GameData.isRoundGame = msg.roundStart;//回合游戏是否开始状态
        GameData.bankerIndex = msg.bankerIndex;
        GameData.ownerIndex = msg.ownerIndex;
        //StageData.GameRoot.clew("庄家:"+msg.bankerIndex+":"+GameData.ownerIndex);
        GameData.roomNo = msg.roomNo;//房间号
        GameData.gameNo = msg.gameNo;
        GameData.maxPlayerCount = msg.maxPlayerCount;//玩家人数	
        GameData.remainCount = msg.remainCount;///剩余的牌数量	
        GameData.payType = msg.payType;///支付类型，1为AA，2为房主支付
        GameData.turns = msg.turns;///剩余回合数
        GameData.totalTurns = msg.totalTurns;////总回合数
        GameData.ruleType = msg.ruleType;///玩法：0扎码；1一码全中；2两个码，3四个码，4六个码
        GameData.outPokerIndex = msg.playIndex;//当前出牌座位号
        GameData.userData = msg.userList;
        let lsSeatIndex:number = GameData.getUserSeatIndex(GameData.mySeatIndex); 
        GameData.myUserData = msg.userList[lsSeatIndex]; 
    }

    // updateRoomOtherOnce: any = _.once(this.updateRoomOther)

    updateRoomOther(msg) {
        console.log('updateRoomOther')
        if (this.lastRoomMsg.userList) {
            if (this.lastRoomMsg.userList.length === msg.userList.length) {
                console.log('updateRoomOther same!')
                return 
            }
        }
        if(GameData.isRoomInfoUpdate == false){
            GameData.isRoomInfoUpdate = true;
            var qxdStr:string = "";
            if(String(msg.qiXiaoDuiWin) == "true"){
                qxdStr = "；七小对可胡";
            }
            //alert(msg.qiXiaoDuiWin);
           // alert("share");
            let shareUrl:string =StageData.linkStr+"/login/weiXin/"+GameData.areaCode+"?roomNo="+GameData.roomNo+"&type=10011";
            // StageData.FXOBJ.setTitle("扎鸟麻将 【房间号:"+GameData.roomNo+"】",GameData.zhifuStr[msg.payType-1]+"；玩法："+GameData.ruleTypeStr[msg.ruleType-1]+ ',' + capsFanStr +"；"+"局数："+msg.totalTurns+qxdStr+"；房间已有"+msg.userList.length+"人",
            //     shareUrl,"icon-pingjiang");
             
            const capsFanStr = msg.capsFan ? '双翻封顶' : '番数无限制'
            var payType
            switch (msg.payType) {
                case 1: 
                    payType = 'AA支付'
                break
                case 2: 
                    payType = '房主支付'
                break
                case 3: 
                    payType = '群主支付'
                break
            }
            const shareContent = `我在帅帅互娱开了${msg.totalTurns}局,${msg.ruleType}个鸟,${capsFanStr},${payType},房间已有${msg.userList.length}人,快来玩吧!`
            StageData.FXOBJ.setTitle("扎鸟麻将 【房间号:"+GameData.roomNo+"】", shareContent, shareUrl, "icon-pingjiang");

        }
    }

    refreshAllPoker(msg) {
        this.centerPoker.addPokerList(msg,this.pointSeatIndex,msg.lastCard); 
        if (this.myPoker && GameData.myUserData) {
            this.updateTingState(msg)
            this.myPoker.tingRolldice(GameData.myUserData.tingRolldice || GameData.myUserData.listenCard === 3)
        }
        //回合已开始
        this.close3RenModel();
        this.readyHide(); 
        for (var i = 0; i < msg.userList.length; i++) {
            let lsobj: any = msg.userList[i];
            if (lsobj.seatIndex == GameData.mySeatIndex) {
                //碰、杠、胡
                // if(lsobj.canDoActions&&lsobj.canDoActions.length>0){
                //     this.winPoker(lsobj);
                // }
                if (lsobj.canDoActions) {
                    if (lsobj.canDoActions.length > 0) {
                        this.winPoker(lsobj)
                    } else {
                        if (this.operationMc && this.operationMc.parent) {
                            this.centerLayerBg.removeChild(this.operationMc)
                        }
                    }
                }
                //玩家赢的牌//actionList////赢牌-碰牌/杠(花色，值，ID，是否抓牌)
                // this.handPokerList[lsobj.seatIndex].winPokerUpdateList(lsobj.actionList);
            } else {
                // this.handPokerList[lsobj.seatIndex].winPokerUpdateList(lsobj.actionList);
            }
            this.handPokerList[lsobj.seatIndex].winPokerUpdateList(lsobj.actionList);

            if (lsobj.handCount > 0) {
                if (lsobj.seatIndex == GameData.mySeatIndex) {
                    this.handPokerList[lsobj.seatIndex].addHandPoker(lsobj.handList, lsobj.lastGetCard);
                } else {
                    this.handPokerList[lsobj.seatIndex].setContent(lsobj.handCount, lsobj.lastGetCard);
                }
            }
        }
    }

    refreshReadyState(msg) {
        let isReady: Boolean = false;
        for (var i = 0; i < msg.userList.length; i++) {
            if (msg.userList[i].seatIndex == GameData.mySeatIndex && msg.userList[i].continueReady == true) {
                isReady = true;
                break;
            }
        }
        if (!isReady) {//自己已准备
            for (var i = 0; i < msg.userList.length; i++) {
                let lsobj: any = msg.userList[i];
                if (lsobj.seatIndex == GameData.mySeatIndex) {
                    //玩家赢的牌//actionList////赢牌-碰牌/杠(花色，值，ID，是否抓牌)  
                    this.handPokerList[lsobj.seatIndex].winPokerUpdateList(lsobj.actionList);
                    this.handPokerList[lsobj.seatIndex].addHandPoker(lsobj.handList, lsobj.lastGetCard);
                    /*隐藏倒牌*/
                    //this.handPokerList[lsobj.seatIndex].openDeal(lsobj.handList,lsobj.lastGetCard);
                } else {
                    this.handPokerList[lsobj.seatIndex].winPokerUpdateList(lsobj.actionList);
                    this.handPokerList[lsobj.seatIndex].setContent(lsobj.handCount, lsobj.lastGetCard);
                    /*隐藏倒牌*/
                    //this.handPokerList[lsobj.seatIndex].openDeal(lsobj.handList,lsobj.lastGetCard);                                
                }
            }
        } else {
            for (var i = 0; i < msg.userList.length; i++) {
                this.handPokerList[msg.userList[i].seatIndex].clearAllPoker();
            }
        }
    }

    /*更新玩家信息*/
    private updateGamePlayInfo(msg){
        GameData.userData = msg;
        let lsSeatIndex:number = GameData.getUserSeatIndex(GameData.mySeatIndex); 
        GameData.myUserData = msg[lsSeatIndex];  
        
        for(var i:number=0;i<4;i++){
            this.ImageList[i].visible = false;
            this.ImageList[i].setOwner(false);
            this.ImageList[i].setBanker(false);
            this.readyList[i].visible = false;
        }

        if(GameData.isGameRunning){//游戏是否已开始
            this.closeReadyBtn();
        }else{
            this.openReadyBtn();
        }

        var reayNum:number = 0;//准备数量
        for(var i=0;i<msg.length;i++){            
           this.ImageList[msg[i].seatIndex].setContent(msg[i].headUrl,msg[i].nickname,msg[i].pointVo.presentPoint,GameData.isUpdateScore);
           this.ImageList[msg[i].seatIndex].allInfo = msg[i]
           this.ImageList[msg[i].seatIndex].visible = true;            
           this.ImageList[msg[i].seatIndex].setOffLine(msg[i].offline);
                        
           if(msg[i].continueReady == true){
                    if(GameData.isRoundGame == false){
                        //回合开始前
                        this.readyList[msg[i].seatIndex].texture = this.readyui.texture;
                        this.readyList[msg[i].seatIndex].visible = true;
                    }                     
                    if(GameData.isGameRunning==false){
                        //游戏为开始前
                        reayNum ++;
                        if(reayNum >= 3&&msg.length == 3){
                            this.open3RenModel();//三人模式
                        }else{
                            this.close3RenModel();
                        }
                        if(msg[i].allow&&msg[i].allow == true){
                            this.readyList[msg[i].seatIndex].texture = this.model3Renui.texture;
                        }
                    }
           }
           //设置准备按钮
                if(msg[i].seatIndex == GameData.mySeatIndex){
                    if(msg[i].ready&&msg[i].ready == true){
                        this.setData(true);  
                    }else{
                        this.setData(false);
                    }
                } 
        }
        //更新三人模式按钮
         if(this.model3ren){
             if(msg[lsSeatIndex].allow){
                 this.model3ren.setContent(msg[lsSeatIndex].allow);
             }else{
                 this.model3ren.setContent(false);
             } 
         } 

        this.ImageList[GameData.ownerIndex].setOwner(true);
        this.ImageList[GameData.bankerIndex].setBanker(true);
        
        //StageData.GameRoot.clew("听牌:"+GameData.isRoundGame+":"+msg[lsSeatIndex].readyList);
        //我的听牌
        if(GameData.isRoundGame==false){
            //在回合游戏结束中
            if(msg[lsSeatIndex].continueReady == false&&msg[lsSeatIndex].readyList&&msg[lsSeatIndex].readyList.length>0){
                this.openTingPoker();
                this.tingPokerMc.setTingPoker(msg[lsSeatIndex].readyList);
            }else{
                //点击了继续游戏
                this.closeTingPoker();  
            }
        }else{
            //在回合游戏开始中
            if(msg[lsSeatIndex]&&msg[lsSeatIndex].readyList&&msg[lsSeatIndex].readyList.length>0){
                //是否有可听的牌
                this.openTingPoker();
                this.tingPokerMc.setTingPoker(msg[lsSeatIndex].readyList);
                //是否开启了听牌托管
                this.tingPokerMc.setTuoGuang(msg[lsSeatIndex].auto);
            }else{
                this.closeTingPoker(); 
            }            
        }            
    }
    //清理游戏所有的牌
    public clearGameAllPoker(){
         for(var i=0;i<4;i++){
             this.handPokerList[i].clearAllPoker();            
         }
         this.centerPoker.clearAllPoker();
         if (this.baotingTishi.parent) {
             this.baotingTishi.parent.removeChild(this.baotingTishi)
         }
         if (this.chipaiTishi.parent) {
             this.chipaiTishi.parent.removeChild(this.chipaiTishi)
         }
    }
    //玩家准备了游戏 10000
    public userReadyGame(msg){
        if (this.baotingTishi.parent) {
            this.baotingTishi.parent.removeChild(this.baotingTishi)
        }
        // StageData.GameRoot.clew("准备:"+msg.ready+":"+GameData.isGameRunning+":"+msg.seatIndex);
        if(GameData.isGameRunning&&msg.seatIndex == GameData.mySeatIndex&&msg.ready==true){
           // alert("准备:"+msg.ready+":"+GameData.isGameRunning+":"+GameData.isRoundGame);
            //if(GameData.isGameRunning&&GameData.isRoundGame == false){//如果游戏已经开始并且回合已结束
                this.closeRoundEnd();//关闭结算界面
                this.clearGameAllPoker();
                this.closeTingPoker();
                this.closeWinEffect();
                this.isWiningShow = false;
                this.closeHuCard();
                if(this.myPoker){
                    this.myPoker.clearThis();//清除手牌和赢的牌
                }
           // } 
        }
    }
    //接收我的手牌
    public acceptHandPoker(msg){
        //回放时消息转接到20002
        if(GameData.roundNo&&msg.seatIndex!=GameData.mySeatIndex){
            this.acceptHandPokerNumber(msg);
            return;
        }
        if(msg.dealCount>5){
            //接收手牌
            // StageData.soundObj.soundSinglePlay("hanCard");
            this.closeTimerDown();
            this.close3RenModel();
            this.readyHide();
            //判断是不是庄家14张牌 
            if(msg.dealCount == 14){
                this.myPoker.addHandPoker(msg.cardList,{suitType:msg.cardList[0].suitType,count:msg.cardList[0].count,cardIndex:msg.cardList[0].cardIndex});
            }else{
                this.myPoker.addHandPoker(msg.cardList,null);
            }
            if (this.baotingTishi.parent) {
                this.baotingTishi.parent.removeChild(this.baotingTishi)
            }
        }else{
            //alert("step:"+GameData.step+":"+msg.step+"-:-"+JSON.stringify(msg));
            if(msg.step<GameData.step){
                this.sendUpdateRoomInfo_msg();
                return;
            }
            
            //接收抓的单张牌
            //我的手牌:{"cardList":[{"cardIndex":4,"count":4,"suitType":"W"}],"commandCode":20001,"dealCount":1,"seatIndex":0,"secure":false,"step":29,"version":"0.1"}
            for(var i=0;i<msg.dealCount;i++){
                this.myPoker.addSinglePoker(msg.cardList[i].suitType,msg.cardList[i].count,msg.cardList[i].cardIndex,true,true);
            }
        }
    }
    
    //接收其他玩家的牌
    public acceptHandPokerNumber(msg){        
        if(msg.dealCount>5){
            //接收手牌          
            if(msg.dealCount == 14){               
                if(GameData.isGameRunning){
                    this.handPokerList[msg.seatIndex].setContent(msg.dealCount,true,msg.cardList);
                }            
            }else{
                this.handPokerList[msg.seatIndex].setContent(msg.dealCount,null,msg.cardList);
            }
            if (this.baotingTishi.parent) {
                this.baotingTishi.parent.removeChild(this.baotingTishi)
            }   
        }else{
            //接收抓的单张牌
            if(GameData.roundNo){//回合//msg.cardList[0].suitType,count:msg.cardList[0].count,cardIndex:msg.cardList[0].cardIndex
                this.handPokerList[msg.seatIndex].addSinglePoker(msg.cardList[0].suitType,msg.cardList[0].count,msg.cardList[0].cardIndex,true);
            }else{
                this.handPokerList[msg.seatIndex].addSinglePoker();
            }
        }
    }
    //轮到某玩家出牌
    public isWhoOutPoker(msg){
        if(GameData.roomNo){//回放
            this.centerPoker.updateTimerPoint(GameData.mySeatIndex,Number(msg.seatIndex)+1);
        }
    }
    //收到某玩家出的牌
    public accepOutPoker(msg){
        //出牌:{"card":{"cardIndex":21,"count":1,"suitType":"T"},"commandCode":20004,"seatIndex":0,"secure":false,"step":18,"version":"0.1"}
       if(msg.seatIndex == GameData.mySeatIndex){
           this.handPokerList[msg.seatIndex].deleteSinglePoker(msg.card.cardIndex);
           this.centerPoker.addSinglePoker(this.pointSeatIndex[msg.seatIndex],msg.card.suitType,msg.card.count,msg.card.cardIndex);
            //this.executeOutPoker(this.outPokerData.x,this.outPokerData.y,msg.card.suitType,msg.card.count,msg.card.cardIndex);           
        }else{
            if(GameData.roomNo){//回放
                this.handPokerList[msg.seatIndex].deleteSinglePoker(msg.card.cardIndex);
                this.centerPoker.addSinglePoker(this.pointSeatIndex[msg.seatIndex],msg.card.suitType,msg.card.count,msg.card.cardIndex);
            }else{
                this.handPokerList[msg.seatIndex].deleteSinglePoker();
                this.centerPoker.addSinglePoker(this.pointSeatIndex[msg.seatIndex],msg.card.suitType,msg.card.count,msg.card.cardIndex);
            }
           //this.executeOutPoker(this.outPokerData.x,this.outPokerData.y,msg.card.suitType,msg.card.count,msg.card.cardIndex);
        }
    }

    //某玩家申请退出房间是否同意
    public agreeExitRoom(msg){
        
        /*let lsName:string = "有人退出房间";//GameData.userData[GameData.getUserSeatIndex(msg.seatIndex)].nickname;
        if(GameData.isGameRunning){            
            if(confirm(lsName+"申请解散游戏，是否同意？")){
                this.sendEixt_msg(true);
            }else{
                this.sendEixt_msg(false);
            }
        }else{
            //alert(lsName+"退出游戏");
        } */       
    }
    //发送退出请求
    private sendEixt_msg(eixt:Boolean){
        let data = {
			commandCode: "11003",
			version: "0.1",
			agree:eixt,
            step:GameData.step
		};
	   Message.sendMsgToServer(data);
    }
    //发送刷新房间信息请求
    private sendUpdateRoomInfo_msg(){
        let data = {
			commandCode: "10003",
			version: "0.1",
            step:GameData.step
		};
        if (Message) {
	        Message.sendMsgToServer(data);
        }
    }
    //赢牌（0过、1吃、2碰、3胡、4明杠、5暗杠、6公杠
    private winPokerGang:number;//保存赢牌杠的代码
    private isHaveHu:boolean = false;//是否有牌动作
    public winPoker(msg){
        //let chi:Boolean = false;
        this.isHaveHu = false;
        let chi:boolean = false;
        let peng:boolean = false;
        let gang:boolean = false;
        let gonggang:boolean = false;
        let hu:boolean = false;   
        let guo:boolean = false;
        let qishouhu:boolean = false; 
        let gangyaoshaizi:boolean = false;   
        let haidiyaoshaizi:boolean = false;      
        let bu: boolean = false;
        let baoting: boolean = false
        let angang: boolean = false

        //alert("t:"+JSON.stringify(msg));
        let msgCanDoActions:any = msg.canDoActions;
        //alert("s:"+JSON.stringify(msgCanDoActions));
        console.log('msgCanDoActions', msgCanDoActions);
        for(var i=0;i<msgCanDoActions.length;i++){
            if(msgCanDoActions[i].actionCode == 0){
                guo = true;
            }
            if(msgCanDoActions[i].actionCode == 1){
                chi = true;
            }
            if(msgCanDoActions[i].actionCode == 2){
                 peng = true;
            }
            if(msgCanDoActions[i].actionCode == 3){
                 hu = true;
                 this.isHaveHu = true;//可以胡牌
            }      
            if(msgCanDoActions[i].actionCode == 4){
                this.winPokerGang = msgCanDoActions[i].actionCode;
                 gang = true;
            }
            if(msgCanDoActions[i].actionCode == 5){
                 angang = true
            }  
            if(msgCanDoActions[i].actionCode == 6){
                 gonggang = true
            }  
            if(msgCanDoActions[i].actionCode == 7){
                 qishouhu = true;
                 this.isHaveHu = true;//可以胡牌
            }
            if(msgCanDoActions[i].actionCode == 8){
                haidiyaoshaizi = true;
            } 
            if(msgCanDoActions[i].actionCode == 9){
                gangyaoshaizi = true;
            }       
            if(msgCanDoActions[i].actionCode == 10){
                bu = true;
            }  
            if(msgCanDoActions[i].actionCode == 11){
                baoting = true;
            }          
        }
        let initSeatIndex:number = 0;
        if(msg.seatIndex){
            initSeatIndex = msg.seatIndex;
        }
       // alert("ZZ:"+initSeatIndex);
        // this.openOperation(msgCanDoActions[0].actionCard,initSeatIndex, msgCanDoActions[0].actionCards);
        this.openOperation(msgCanDoActions[0].actionCard,initSeatIndex, msgCanDoActions);
        this.operationMc.setContent({peng, gang, gonggang, hu, guo, chi, qishouhu, gangyaoshaizi, haidiyaoshaizi, bu, baoting, angang})
        this.operationMc.setWinPokerMsg(msg)
        this.operationSize();
        const chilede = GameData.myUserData && GameData.myUserData.actionList.some(action => action.actionType === 'CHI')
        if (chi && !chilede) {
            this.centerLayerBg.addChild(this.chipaiTishi)
            this.chipaiTishi.x = 478
            this.chipaiTishi.y = 338
            this.chipaiTishi.scaleX = 1.5
            this.chipaiTishi.scaleY = 1.5
        } else if (this.chipaiTishi.parent){
            this.centerLayerBg.removeChild(this.chipaiTishi)
        }
        /*赢牌:{"canDoActions":[{"actionCard":{"cardIndex":29,"count":9,"suitType":"T"},"actionCode":2,"actionIndex":2,"actionType":"PENG"}],"commandCode":20009,"secure":false,"step":28,"version":"0.1"}*/
    }
    //某玩家可能要碰、胡、牌
    public whoWin(){
        this.centerPoker.updateTimerPoint(-1,-1);
    }
    //某玩家碰、杠、胡
    public winMsg
    public getWinPoker(msg){
        this.winMsg = msg
        this.centerPoker.clearPointer()
        if (this.chipaiTishi.parent){
            this.centerLayerBg.removeChild(this.chipaiTishi)
        }
        //alert("delete:"+this.deleteNumber);
       // this.deleteNumber ++;
        if(msg.step<GameData.step){
            this.sendUpdateRoomInfo_msg();
            return;
        }
        
        if(GameData.roundNo){//是否回放            
            this.closeOperation();
        }else{
            if(msg.seatIndex == GameData.mySeatIndex){
                this.closeOperation();//actionList////赢牌-碰牌/杠(花色，值，ID，是否抓牌)
            } 
        }               
        
        if(GameData.winPokerCode[msg.action.actionCode] == "hu"){
            this.openWinEffect("hu",0,msg.winnerSet);
            // this.playHuCardEffect();
            // const seatIndexList = msg.winnerSet
            // for(var i=0;i<seatIndexList.length;i++){
            //     var lswineffect = new winEffect('hu');
            //         lswineffect.x = StageData.W/2;//this.readyList[seatIndexList[i]].x;
            //         lswineffect.y = StageData.H/2;//this.readyList[seatIndexList[i]].y;
            //         this.centerLayerBg.addChild(lswineffect);
            //         this.huCardObj.push(lswineffect);//this.ImageXyList[2].x
            //         egret.Tween.get(lswineffect).wait(600).to({scaleX:2,scaleY:2},1000).wait(1000)
            //         .to({x:this.ImageList[seatIndexList[i]].x+(this.ImageList[seatIndexList[i]].width/2),y:this.ImageList[seatIndexList[i]].y+(this.ImageList[seatIndexList[i]].height/2),scaleX:1,scaleY:1},1000);
            // }
            // -1 为自摸
            // if (msg.actionIndex === -1) {
            //     msg.winnerSet.forEach(winnerSeatIndex => {
            //         // const user = GameData.userData.find(data => data.seatIndex === winnerSeatIndex)

            //     }) 
            // } else {

            // }
        }else if(GameData.winPokerCode[msg.action.actionCode] == "guo"){
            //过
        }else{
            /*if(GameData.winPokerCode[msg.action.actionCode] != "gonggang"&&GameData.winPokerCode[msg.action.actionCode] != "angang"&&GameData.winPokerCode[msg.action.actionCode] != "liuju"){
                this.centerPoker.deleteNewOutCard();
            }*/    
            console.log('msg.action', msg.action);
            var code = ''
            if (msg.action.actionType === 'BU_CARD') {
                code = 'bu_card'
            } else {
                code = GameData.winPokerCode[msg.action.actionCode]
            }
            this.openWinEffect(code, msg.seatIndex);
            let chidepai = msg.action.actionCards ? msg.action.actionCards[0].count : null
            this.handPokerList[msg.seatIndex].winPoker(msg.action.actionCard.suitType,msg.action.actionCard.count,msg.action.actionCard.cardIndex,GameData.winPokerCode[msg.action.actionCode], chidepai);
        }
        this.onStageSize();
        this.sendUpdateRoomInfo_msg()
        //杠Penguin：{"action":{"actionCard":{"cardIndex":2,"count":2,"suitType":"W"},"actionCode":2,"actionIndex":2,"actionType":"PENG"},"commandCode":20010,"seatIndex":0,"secure":false,"step":40,"version":"0.1"}
    }
    //发送碰、杠、胡请求
    private sendWin_msg(code:number,isHu:boolean=false){
        let data = {
			commandCode: "20003",
			version: "0.1",
			actionCode:code,
            crossHu:isHu,
            step:GameData.step
		};
	   Message.sendMsgToServer(data);
    }
    //接收到听牌托管
    public getTingPoker(msg){
        if(msg.seatIndex == GameData.mySeatIndex&&this.tingPokerMc){
            this.tingPokerMc.setTuoGuang(msg.auto);
        }
    }
    //更新用户分数
    public updateUserPoint(){
        let msg:any = GameData.userData;
        if(!msg) return;
        for(var i=0;i<msg.length;i++){ 
           this.ImageList[msg[i].seatIndex].setScore(msg[i].pointVo.presentPoint);
        }
    }
    //回合结算
    public getRoundEnd(msg){        
        this.isyesReconnect = false;
        //重连时如果中码已经显示过了就不显示了        
        if(this.isWiningShow){
           /* this.openRoundEnd(msg);*/
        }else{
            StageData.soundObj.soundSinglePlay("outCard");
            if(msg.winnerSet&&msg.winnerSet.length>0){
                //胡牌
                //let lsTimer0 = egret.setTimeout(()=>{
                //    egret.clearTimeout(lsTimer0);

                // this.openWinEffect("hu",0,msg.winnerSet);

                //},this,1000);
                GameData.isUpdateScore = false;//禁止玩家分数更新
                let lsTimer = egret.setTimeout(()=>{
                    // StageData.soundObj.soundSinglePlay("over_ok");
                    egret.clearTimeout(lsTimer);
                    this.openWinningCard(msg);
                    if (this.haidipai && this.haidipai.parent) {
                        this.centerLayerBg.removeChild(this.haidipai)
                    }
                    if (this.haidilaoLabel && this.haidilaoLabel.parent) {
                        this.centerLayerBg.removeChild(this.haidilaoLabel)
                    }
                },this,2000);
            }else{
                //流局
                //let lsTimer0 = egret.setTimeout(()=>{
                //    egret.clearTimeout(lsTimer0);
                    // this.openWinEffect("liuju",0);
                //},this,1000);        
                let lsTimer = egret.setTimeout(()=>{
                    egret.clearTimeout(lsTimer);
                    if (this.haidipai && this.haidipai.parent) {
                        this.centerLayerBg.removeChild(this.haidipai)
                    }
                    if (this.haidilaoLabel && this.haidilaoLabel.parent) {
                        this.centerLayerBg.removeChild(this.haidilaoLabel)
                    }
                    this.openRoundEnd(msg)
                    this.updateUserPoint()//刷新分数
                },this,1000)
            }
        }        
    }

    public qishouhuShow(msg) {
        // const fixedQishouIndex = msg.seatIndex - GameData.myUserData.seatIndex >= 0 ?
        //  msg.seatIndex - GameData.myUserData.seatIndex : msg.seatIndex - GameData.myUserData.seatIndex + 4
        console.log('qishouhuShow', msg);
        setTimeout(() => {
            msg.zhongMa.forEach((ma, index) => {
                const luckyYao = new Yaoshaizidange()
                luckyYao.x = 500 + index * 120;//15+(32*((i+1)%5));
                luckyYao.y = 200;//8+(Math.floor((i+1)/5)*(45)); 
                this.centerLayerBg.addChild(luckyYao)
                console.log('luckyYao', luckyYao);
                luckyYao.playAction(ma.count, true)
                luckyYao.once('playEnd', function () {
                    setTimeout(() => {
                        this.centerLayerBg.removeChild(luckyYao)
                    }, 2000)
                }, this)
            })
        }, 1000)
        setTimeout(() => {
            console.log('this.ImageXyList', this.ImageXyList);
            StageData.soundObj.soundSinglePlay("effecttingpai");
            msg.startSettlemens.forEach((settle, index) => {
                const fixedSeat = settle.seatIndex - GameData.myUserData.seatIndex >= 0 ? settle.seatIndex - GameData.myUserData.seatIndex :
                 settle.seatIndex - GameData.myUserData.seatIndex + 4
                const {x, y} = this.ImageXyList[fixedSeat]
                const fenLabel = new eui.BitmapLabel()
                fenLabel.width = 240
                fenLabel.x = x
                fenLabel.y = y
                if (settle.point >= 0) {
                    fenLabel.font = "font_point-Jia_fnt";
                    fenLabel.text = "+" + settle.point;
                } else {
                    fenLabel.font = "font_point-jian_fnt";
                    fenLabel.text = settle.point;
                }
                this.centerLayerBg.addChild(fenLabel)
                setTimeout(() => {
                    this.centerLayerBg.removeChild(fenLabel)
                }, 3000)
            })
        }, 5000)
        // action  起手胡的动作：
        // {
        //     actionType：7（起手胡）
        //     actionCardMap	{
        //         type（1.是大四喜，2是六六顺，3缺一色，4板板胡）
        //         cards：需要展示的牌（跟局上面的type展示，大四喜展示4张，六六顺展示3张，其他2种全部展示）
        //     }
        // }
        const isMySelf = msg.seatIndex === GameData.myUserData.seatIndex
        console.log(this.handPokerList, this.handPokerList);
        const huTypes = msg.action.actionCardMap.map(map => map.type)
        const huVoices = huTypes.map(type => {
            switch (type) {
                case 1:
                return 'dasixi'
                case 2:
                return 'liuliushun'
                case 3:
                return 'queyise'
                case 4:
                return 'banbanhu'
            }
        })
        console.log('huVoices', huVoices);
        huVoices.forEach((voice, index) => {
            setTimeout(() => {
                this.openWinEffect(voice, msg.seatIndex)
            }, index * 3000)
        })
        if (isMySelf) {
            this.myPoker.qishouhula(msg)
        } else {
            this.handPokerList[msg.seatIndex].qishouhula(msg)
        }
    }
    private haidipai
    private haidilaoLabel
    public getHaidiResult(msg) {
        console.log('haidi result', msg);
        if (this.haidipai && this.haidipai.parent) {
            this.centerLayerBg.removeChild(this.haidipai)
        }
        if (this.haidilaoLabel && this.haidilaoLabel.parent) {
            this.centerLayerBg.removeChild(this.haidilaoLabel)
        }
        // if (!msg.card) {
        //     return
        // }
        StageData.soundObj.soundSinglePlay("tingCard");
        const pai = new TanpaiMy()
        pai.scaleX = pai.scaleY = 2
        pai.x = 520
        pai.y = 290
        if (!msg.card) {
            pai.setBack()
        } else {
            pai.setData(msg.card)
        }
        const haidilaoLabel = MyLibrary.createBitmapByName('haidilao_png')
        haidilaoLabel.x = 430
        haidilaoLabel.y = 200
        haidilaoLabel.scaleX = haidilaoLabel.scaleY = .7
        this.centerLayerBg.addChild(pai)
        this.centerLayerBg.addChild(haidilaoLabel)
        this.haidipai = pai
        this.haidilaoLabel = haidilaoLabel
        // setTimeout(() => {
        //     this.centerLayerBg.removeChild(pai)
        //     this.centerLayerBg.removeChild(haidilaoLabel)
        // }, 3000)
    }

    public baotingle(msg) {
        console.log('baotingle', msg);
        StageData.soundObj.soundSinglePlay("tingla")
        this.centerLayerBg.addChild(this.baotingTishi)
    }
    public initedTingState: boolean = false
    public tingShowList = []
    public baotingTishi = MyLibrary.createBitmapByName('baitingtishixinxi_png')
    public chipaiTishi = MyLibrary.createBitmapByName('chipaitishixinxi_png')
    public updateTingState(msg) {
        console.log('updateTingState', this.readyXYList);
        if (!this.initedTingState) {
            for (let i = 0; i < 4; i++) {
                var img = MyLibrary.createBitmapByName('baotinging_png')
                this.tingShowList.push(img)
            }
            this.initedTingState = true
        }
        if (!msg.roundStart) {
            this.tingShowList.forEach(ting => {
                if (ting.parent) {
                    this.centerLayerBg.removeChild(ting)
                }
            })
            return
        }
        msg.userList.forEach(user => {
            const tingComponent = this.tingShowList[user.seatIndex]
            if (user.listenCard === 3) {
                this.centerLayerBg.addChild(tingComponent)
                const fixed = user.seatIndex - GameData.mySeatIndex < 0 ? user.seatIndex - GameData.mySeatIndex + 4 : user.seatIndex - GameData.mySeatIndex
                var point = this.readyXYList[fixed]
                tingComponent.x = point.x
                tingComponent.y = point.y
            } else if (tingComponent.parent){
                this.centerLayerBg.removeChild(tingComponent)
            }
        })
        if (msg.userList.some(user => user.listenCard === 3)) {
            this.centerLayerBg.addChild(this.baotingTishi)
            this.baotingTishi.x = 478
            this.baotingTishi.y = 438
        } else if (this.baotingTishi.parent){
            this.centerLayerBg.removeChild(this.baotingTishi)
        }
    }
}
